<?php
code();
function code($width = 200, $height = 60, $length = 4, $dots = 500, $lines = 10, $arcs = 10) {
    header('content-type:image/png');
    $lower = range("a", "z");
    $upper = range("A", "Z");
    $num = range("0", "9");
    $string = implode("", array_merge($lower, $upper, $num));
    $image = imagecreatetruecolor($width, $height);
    $white = imagecolorallocate($image, 255, 255, 255);
    imagefill($image, 0, 0, $white);
    for ($index = 0; $index < $length; $index++) {
        $size = mt_rand(18, 24);
        $angle = mt_rand(-45, 45);
        $x = 10 + $index * $width / $length;
        $y = mt_rand($size * 3 / 2, $height - $size / 2);
        $fontcolor = imagecolorallocate($image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
        $fontfamily = 'msyh.ttf';
        $text = substr($string, mt_rand(0, mb_strlen($string) - 1), 1);
        imagettftext($image, $size, $angle, $x, $y, $fontcolor, $fontfamily, $text);
    }
    for ($index1 = 0; $index1 < $dots; $index1++) {
        $x = mt_rand(0, $width);
        $y = mt_rand(0, $height);
        $dotcolor = imagecolorallocate($image, mt_rand(100, 200), mt_rand(100, 200), mt_rand(100, 200));
        imagesetpixel($image, $x, $y, $dotcolor);
    }
    for ($index2 = 0; $index2 < $lines; $index2++) {
        $x1 = mt_rand(0, $width);
        $y1 = mt_rand(0, $height);
        $x2 = mt_rand(0, $width);
        $y2 = mt_rand(0, $height);
        $linecolor = imagecolorallocate($image, mt_rand(100, 200), mt_rand(100, 200), mt_rand(100, 200));
        imageline($image, $x1, $y1, $x2, $y2, $linecolor);
    }
    for ($index3 = 0; $index3 < $lines; $index3++) {
        $cx = mt_rand(0, $width);
        $cy = mt_rand(0, $height);
        $w = mt_rand(0, $width / 2);
        $h = mt_rand(0, $height / 2);
        $s = mt_rand(0, 180);
        $e = mt_rand(180, 360);
        $arccolor = imagecolorallocate($image, mt_rand(100, 200), mt_rand(100, 200), mt_rand(100, 200));
        imagearc($image, $cx, $cy, $w, $h, $s, $e, $arccolor);
    }
    imagepng($image);
    imagedestroy($image);
}
